import request from '../../utils/request';

/**
 *添加产品
 *
 * @param params
 * @returns {Promise.<void>}
 */

export async function createproduct({ productname, productquantity, productmodel, memo}) {
    return request(apiPath.mc + "/api/product", {
        method: 'post',
        data: { productname, productquantity, productmodel, memo }
    });
}

/**
 *修改产品信息
 *
 * @param params
 * @returns {Promise.<void>}
 */
 export async function updateProduct({ dataSource }){
     return request(apiPath.mc + "/api/product", {
         method: 'put',
         data:{...dataSource}
     } );
}

/**
 *根据id删除产品
 *
 * @param params
 * @returns {Promise.<void>}
 */
export async function deleteProductById({ id }) {
    return request(apiPath.mc + "/api/product/" + id, {
        method: 'delete'
    });
}

/**
 *根据id获取产品信息
 *
 * @param params
 * @returns {Promise.<void>}
 */
export async function getProductById({ id }) {
    return request(apiPath.mc + "/api/product/" + id, {
        method: 'get'
    });
}

/**
 *根据客户id分页查询产品信息
 *
 * @param params
 * @returns {Promise.<void>}
 */
export async function getListByCstId({ cstId, status, productName, productModel, page }) {
    return request(apiPath.mc + "/api/product/" + cstId, {
        method: 'get'
    });
}